@extends('app')

@section('content')
<ul class="nav nav-tabs">
    <li class="active"><a href="#">信息列表</a></li>
</ul>

<div class="form-inline mt20">

    <form class="form-inline" action="#" method="get">
        <div class="form-group">
            <label for="exampleInputAmount">机构：</label>
            <select name="organization" class="form-control" onchange="selectCourse(this.value,'/admin/organization/course/query','{{ csrf_token() }}')">
                <option value="0">--无--</option>
                @foreach($organizations as $org)
                <option value="{{ $org->id }}" @if($org->id == $oid) selected @endif>{{ $org->name }}</option>
                @endforeach
            </select>
        </div>
        <div class="form-group">
            <label for="exampleInputAmount">课程：</label>
            <select name="course" id="course" class="form-control" >
                <option value="0">--无--</option>
                @foreach($courses as $cou)
                <option value="{{ $cou->id }}" @if($cou->id == $cid) selected @endif>{{ $cou->name }}</option>
                @endforeach
            </select>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail2">评分</label>
            <input type="text" class="form-control" id="exampleInputEmail2" name="score" value="{{ $qurey_score }}">
        </div>
        <button type="submit" class="btn btn-primary">提交</button>
    </form>
</div>

<div class="panel panel-default mt20">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
            <thead>
            <tr>
                <th>编号</th>
                <th>课程</th>
                <th>用户</th>
                <th>费用</th>
                <th>总体评分</th>
                <th>内容</th>
                <th>回复数</th>
                <th>发布时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            @foreach($score as $res)
            <tr id="news_{{ $res->id }}">
                <td>{{ $res->id }}</td>
                <td><a href="{{ url('/teaches/orgcourse/'.$res->c_id)}} ">{{ str_limit($res->cname,16)}}</a></td>
                <td>{{getUserName($res->u_id)}}</td>
                <td>{{ ($res->cost>0)?$res->cost:'无'}}</td>
                <td>{{ $res->score}}星</td>
                <td><a href="javascript:void(0)"  onclick="showComment('{{$res->content}}')">{{ str_limit($res->content,20)}}</a></td>
                <td>{{ $res->childComments->count()}}</td>
                <td>{{ $res->updated_at}}</td>
                <td>
                    <a href="javascript:void(0);" onclick="del_one('/admin/teaches/class/comment/delete','{{$res->id}}','{{csrf_token()}}','id')">
                        <i class="glyphicon glyphicon-remove-sign"></i>
                    </a>
                </td>
            </tr>
            @endforeach
            </tbody>
        </table>
    </div>
</div>
<div>{!! $score->render() !!} </div>
@endsection

<script type="text/javascript">
    function selectCourse(id,url,token)
    {
        $.ajax({
            'url':url,
            'type':'POST',
            'data':"id="+id+'&_token='+token,
            success: function(data){
                if(data.status == 'success'){
                    result = data.data;
                    option = '<option value="0">--无--</option>';
                    $.each(result, function(k,e){
                        option += '<option value="'+e.id+'">'+e.name+'</option>';
                    });
                    $("#course").html(option);
                }

            }
        });
    }
</script>
